#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <resolv.h>

int main() {
    const unsigned char *src = (const unsigned char *)"Hello, World!";
    size_t srclength = strlen((const char *)src);
    char *dst;
    size_t dstlength;

    // 计算需要的输出缓冲区大小
    dstlength = srclength * 4 / 3 + 4;
    dst = malloc(dstlength);
    if (dst == NULL) {
        fprintf(stderr, "Memory allocation failed\n");
        return 1;
    }

    // 执行Base64编码
    dstlength = b64_ntop(src, srclength, dst, dstlength);
    if (dstlength == -1) {
        fprintf(stderr, "Base64 encoding failed\n");
        free(dst);
        return 1;
    }

    printf("Encoded: %s\n", dst);

    free(dst);
    return 0;
}